import request from '@/service/request'
import { IResponse } from './type/index.type'
import {
  ICategoryResponse,
  ICurCategoryResponse,
  ICurCategory,
  ISubCategory,
  ISubCategoryResponse
} from './type/category.type'

export const findAllCategory = () =>
  request<ICategoryResponse, IResponse<ICategoryResponse>>(
    '/home/category/head',
    'get'
  )

export const findCurrentCategory = (id: string) => {
  return request<ICurCategory, ICurCategoryResponse>('/category', 'get', {
    id
  })
}

export const findSubCategory = (id: string) => {
  return request<ISubCategory, ISubCategoryResponse>(
    '/category/sub/filter',
    'get',
    {
      id
    }
  )
}
